Repository navigation
Fix regression cooldown bars - #1154
Conversation
WalkthroughThe logic for displaying cooldown progress bars for MissileSilo and SAMLauncher units in the UI layer was refactored. Now, each unit type checks its own cooldown and uses the correct configuration value for its cooldown duration. Duplicate progress bars are avoided by checking existing tracked bars. Changes
Sequence Diagram(s)sequenceDiagram
participant UILayer
participant Unit
participant Config
UILayer->>Unit: Check unit type (MissileSilo or SAMLauncher)
UILayer->>Unit: IsActive? InCooldown? Not in allProgressBars?
alt MissileSilo
UILayer->>Config: Get SiloCooldown()
UILayer->>UILayer: Draw progress bar with SiloCooldown
else SAMLauncher
UILayer->>Config: Get SAMCooldown()
UILayer->>UILayer: Draw progress bar with SAMCooldown
end
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/client/graphics/layers/UILayer.ts (1)
140-147: Duplicate logic – extract small helper for compositionThe SAM and silo blocks differ by one line (
SiloCooldown()vsSAMCooldown()). Copy-pasting hurts readability and future changes.-const endTick = this.game.config().SAMCooldown(); -this.drawLoadingBar(unit, endTick); +this.drawCooldownBar(unit, this.game.config().SAMCooldown());And introduce:
private drawCooldownBar(unit: UnitView, totalTicks: Tick) { if (unit.isActive() && unit.isInCooldown() && !this.allProgressBars.has(unit.id())) { this.drawLoadingBar(unit, totalTicks); } }Small helper = less branching, easier tests, fits the “prefer composition” rule.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/client/graphics/layers/UILayer.ts(1 hunks)
🔇 Additional comments (1)
src/client/graphics/layers/UILayer.ts (1)
130-138: Progress starts from 0 even when cooldown already consumed
startTickis always set tothis.game.ticks()indrawLoadingBar.
If the silo has already spent part of its cooldown before the client noticed it, the bar will show 0 % instead of the real remaining time. Prefer passing remaining ticks instead of the fullSiloCooldown()duration.-const endTick = this.game.config().SiloCooldown(); +const endTick = unit.cooldownRemaining?.() ?? this.game.config().SiloCooldown();This keeps the bar in sync when the UI joins a running match or after reconnects.
## Description: Changes in unit cooldown introduced a bug in the loading bars This fixes it. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: Vivacious Box
Changes in unit cooldown introduced a bug in the loading bars This fixes it. - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors regression is found: Vivacious Box
## Description: The Clans modal's **Map** tab now opens the clan map as **its own full-screen page** instead of fitting it into the modal. **Why:** inside the modal, the map sat in a column about 550 px wide. It opened at about 0.22× zoom with large empty bands above and below, and members who aren't leaders or officers saw only a bare map. A UI review of the clan map named this as the biggest problem. **What players see:** - Clicking **Map** fills the screen with the map, in the game's style (the restyle is in openfrontio/infra#1153). - A **← Clans** button at the top left goes back to the list they came from. - The map page's panel (claim land, territory list, totals) floats on the right for **everyone**, and can be hidden to see the whole map. - On a phone, the panel starts closed and docks at the bottom when opened. **How:** - `ClanModal` renders the page into its own element on `<body>` (`syncMapPage`). A `fixed` element inside the modal is positioned against the modal's box, not the screen; I hit this when testing. - The page is mounted only while the modal is open on the Map tab, as before, so the map isn't polling in the background. - `ClanMapView` has a new `full` property that frames the map with `?full=1`, asking the map page for its full-screen layout. That layout is in openfrontio/infra#1154. - The frame and spinner background is now `#3c3c3c`, matching the map. - New text: `clan_modal.map_back` ("Back to clans"), the back button's aria-label. The button's visible text reuses `clan_modal.title`. **Merge order:** the infra changes (openfrontio/infra#1153, then #1154) should deploy first. Until they do, `?full=1` is ignored and the map page uses its embedded layout at full-screen size. That layout works but has no side panel for players who can't claim land. **Translation** (second commit): the map page is served by the API inside a frame, so it can't call `translateText`. - `ClanMapView` now answers every `clanmap:ready` with `{ type: "clanmap:lang", rtl, strings }` before the JWT, signed in or not. It's posted to the map's origin only. - `strings` holds every `clan_map.*` template in the player's language, falling back to English, unformatted (new `translationTemplates` in `Utils`). The page formats them itself (openfrontio/infra#1157). - The page's 180 English strings are added to `en.json` under `clan_map`, so Crowdin picks them up. - `TranslationSystem.test` ignores them for the unused-key check, like the desktop shell's strings, since no `translateText` call here uses them. ### Screenshots All from this branch running locally (`vite` on :9100), with the map page from openfrontio/infra#1154 served locally. The map data is the **real live map**, read through the public read-only endpoints. Signed out. The live map is currently paused for maintenance, which is why the bar shows. **Before:** the Map tab inside the modal (current production) <img width="640" alt="Before: the map inside the Clans modal" src="https://github.com/user-attachments/assets/0e47418f-d9ec-4f7d-8072-96f4c0ef3505" /> **After:** the Map tab opens a full-screen page <img width="640" alt="After: full-screen clan map" src="https://github.com/user-attachments/assets/712f6081-8068-4d3d-b404-8f9c6b1de140" /> **After:** the panel hidden to see the whole map <img width="640" alt="After: panel hidden" src="https://github.com/user-attachments/assets/fd5067d2-5ae2-4eef-94ea-4e1aed46b0f4" /> **After:** ← Clans returns to the list <img width="480" alt="After: back on the clan list" src="https://github.com/user-attachments/assets/eb35d006-12b9-42ee-8aaa-ff84ff2550db" /> **Phone:** the panel starts closed, then opened <img width="240" alt="Phone: panel closed" src="https://github.com/user-attachments/assets/b874e6d0-906a-421a-a026-a14ddd851909" /> <img width="240" alt="Phone: panel open" src="https://github.com/user-attachments/assets/28341c99-78fd-4fc0-a6d8-3b0e95238797" /> **Translation:** a few sample French strings put into the game's language data by hand (`fr.json` won't have `clan_map.*` until Crowdin translates it). They arrive in the map; everything else falls back to English. <img width="640" alt="Sample French strings in the clan map" src="https://github.com/user-attachments/assets/5fb10acc-a43d-47b3-9773-fe49cd7ae0c2" /> ### Tests - `ClanModalGuest.test.ts`: the Map tab opens a full-screen page on `<body>` framing the map with `full`, and **← Clans** returns to My Clans and removes the page. - `ClanMapView.test.ts`: `full` adds `?full=1` to the frame's URL. - `ClanModalProfileHandoff.test.ts`: the "mounted only while open" test now looks on `<body>`. - `TranslationTemplates.test.ts`: every key under the prefix, in the player's language over English, unformatted. - `ClanMapView.test.ts`: `clanmap:lang` is sent before the JWT, and a signed-out viewer gets the text without a JWT. - Run locally: `tests/client/clan`, `TranslationTemplates`, `TranslationSystem`, `EnJsonSorted` (478 passed) and `LayerBoundaries`, `tsc --noEmit`, oxlint and oxfmt on the changed files. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: iamlewis 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
## Description: The Clans modal's **Map** tab now opens the clan map as **its own full-screen page** instead of fitting it into the modal. **Why:** inside the modal, the map sat in a column about 550 px wide. It opened at about 0.22× zoom with large empty bands above and below, and members who aren't leaders or officers saw only a bare map. A UI review of the clan map named this as the biggest problem. **What players see:** - Clicking **Map** fills the screen with the map, in the game's style (the restyle is in openfrontio/infra#1153). - A **← Clans** button at the top left goes back to the list they came from. - The map page's panel (claim land, territory list, totals) floats on the right for **everyone**, and can be hidden to see the whole map. - On a phone, the panel starts closed and docks at the bottom when opened. **How:** - `ClanModal` renders the page into its own element on `<body>` (`syncMapPage`). A `fixed` element inside the modal is positioned against the modal's box, not the screen; I hit this when testing. - The page is mounted only while the modal is open on the Map tab, as before, so the map isn't polling in the background. - `ClanMapView` has a new `full` property that frames the map with `?full=1`, asking the map page for its full-screen layout. That layout is in openfrontio/infra#1154. - The frame and spinner background is now `#3c3c3c`, matching the map. - New text: `clan_modal.map_back` ("Back to clans"), the back button's aria-label. The button's visible text reuses `clan_modal.title`. **Merge order:** the infra changes (openfrontio/infra#1153, then #1154) should deploy first. Until they do, `?full=1` is ignored and the map page uses its embedded layout at full-screen size. That layout works but has no side panel for players who can't claim land. **Translation** (second commit): the map page is served by the API inside a frame, so it can't call `translateText`. - `ClanMapView` now answers every `clanmap:ready` with `{ type: "clanmap:lang", rtl, strings }` before the JWT, signed in or not. It's posted to the map's origin only. - `strings` holds every `clan_map.*` template in the player's language, falling back to English, unformatted (new `translationTemplates` in `Utils`). The page formats them itself (openfrontio/infra#1157). - The page's 180 English strings are added to `en.json` under `clan_map`, so Crowdin picks them up. - `TranslationSystem.test` ignores them for the unused-key check, like the desktop shell's strings, since no `translateText` call here uses them. ### Screenshots All from this branch running locally (`vite` on :9100), with the map page from openfrontio/infra#1154 served locally. The map data is the **real live map**, read through the public read-only endpoints. Signed out. The live map is currently paused for maintenance, which is why the bar shows. **Before:** the Map tab inside the modal (current production) <img width="640" alt="Before: the map inside the Clans modal" src="https://github.com/user-attachments/assets/0e47418f-d9ec-4f7d-8072-96f4c0ef3505" /> **After:** the Map tab opens a full-screen page <img width="640" alt="After: full-screen clan map" src="https://github.com/user-attachments/assets/712f6081-8068-4d3d-b404-8f9c6b1de140" /> **After:** the panel hidden to see the whole map <img width="640" alt="After: panel hidden" src="https://github.com/user-attachments/assets/fd5067d2-5ae2-4eef-94ea-4e1aed46b0f4" /> **After:** ← Clans returns to the list <img width="480" alt="After: back on the clan list" src="https://github.com/user-attachments/assets/eb35d006-12b9-42ee-8aaa-ff84ff2550db" /> **Phone:** the panel starts closed, then opened <img width="240" alt="Phone: panel closed" src="https://github.com/user-attachments/assets/b874e6d0-906a-421a-a026-a14ddd851909" /> <img width="240" alt="Phone: panel open" src="https://github.com/user-attachments/assets/28341c99-78fd-4fc0-a6d8-3b0e95238797" /> **Translation:** a few sample French strings put into the game's language data by hand (`fr.json` won't have `clan_map.*` until Crowdin translates it). They arrive in the map; everything else falls back to English. <img width="640" alt="Sample French strings in the clan map" src="https://github.com/user-attachments/assets/5fb10acc-a43d-47b3-9773-fe49cd7ae0c2" /> ### Tests - `ClanModalGuest.test.ts`: the Map tab opens a full-screen page on `<body>` framing the map with `full`, and **← Clans** returns to My Clans and removes the page. - `ClanMapView.test.ts`: `full` adds `?full=1` to the frame's URL. - `ClanModalProfileHandoff.test.ts`: the "mounted only while open" test now looks on `<body>`. - `TranslationTemplates.test.ts`: every key under the prefix, in the player's language over English, unformatted. - `ClanMapView.test.ts`: `clanmap:lang` is sent before the JWT, and a signed-out viewer gets the text without a JWT. - Run locally: `tests/client/clan`, `TranslationTemplates`, `TranslationSystem`, `EnJsonSorted` (478 passed) and `LayerBoundaries`, `tsc --noEmit`, oxlint and oxfmt on the changed files. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: iamlewis 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a8b97d8)
Description:
Changes in unit cooldown introduced a bug in the loading bars
This fixes it.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
Vivacious Box